package forum.entities;

import java.math.BigInteger;

public class Category extends Entity {

    private String categoryName;
    private BigInteger parentCategoryId;
    private BigInteger authorId;

    public Category(BigInteger id) {
        super(id);
    }

    public Category(BigInteger id, String categoryName) {
        super(id);
        this.categoryName = categoryName;
    }

    public Category(BigInteger id, String categoryName, BigInteger parentCategoryId, BigInteger authorId) {
        super(id);
        this.categoryName = categoryName;
        this.parentCategoryId = parentCategoryId;
        this.authorId = authorId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public BigInteger getParentCategoryId() {
        return parentCategoryId;
    }

    public void setParentCategoryId(BigInteger parentCategoryId) {
        this.parentCategoryId = parentCategoryId;
    }

    public BigInteger getAuthorId() {
        return authorId;
    }

    public void setAuthorId(BigInteger authorId) {
        this.authorId = authorId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (! (o instanceof Category)) return false;
        if (! super.equals(o)) return false;

        Category category = (Category) o;

        if (authorId != null ? ! authorId.equals(category.authorId) : category.authorId != null) return false;
        if (categoryName != null ? ! categoryName.equals(category.categoryName) : category.categoryName != null)
            return false;
        if (parentCategoryId != null ? ! parentCategoryId.equals(category.parentCategoryId) : category.parentCategoryId != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (categoryName != null ? categoryName.hashCode() : 0);
        result = 31 * result + (parentCategoryId != null ? parentCategoryId.hashCode() : 0);
        result = 31 * result + (authorId != null ? authorId.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Category{" +
                "categoryName='" + categoryName + '\'' +
                ", parentCategoryId=" + parentCategoryId +
                ", authorId=" + authorId +
                "} " + super.toString();
    }
}
